package projeto.piloto;


import java.io.IOException;
import java.io.InputStream;

import projeto.piloto.R;
import android.app.Activity;
import android.content.Intent;
import android.content.res.AssetManager;
import android.os.Bundle;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

public class HelpActivity extends Activity{
	@Override
    public void onCreate(Bundle savedInstanceState) {
    	
    	
        super.onCreate(savedInstanceState);
        
        //Remove title bar
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);

        //Remove notification bar
        this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
        
        getWindow().setSoftInputMode(
                WindowManager.LayoutParams.SOFT_INPUT_STATE_HIDDEN);
        
        
        setContentView(R.layout.help);
        showHelp();
	}
	
    @Override
    public void onBackPressed() {
       Intent trocatela = new Intent(HelpActivity.this, AnagramaActivity.class);
       HelpActivity.this.startActivity(trocatela);
       HelpActivity.this.finish();
        		 
       return;
    }
    
    public void showHelp(){
		TextView help = (TextView)findViewById(R.id.textView4);
		try {
	
	    	AssetManager am = this.getAssets();
			InputStream is = am.open("help.txt");			
			help.setText(convertStreamToString(is));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
    	
    	
    }
    
    public String convertStreamToString(java.io.InputStream is) {
        try {
            return new java.util.Scanner(is).useDelimiter("//Z").next();
        } catch (java.util.NoSuchElementException e) {
            return "";
        }
    }
    
    
    
}
